<template>
  <div class="page-container">
    <div class="iconfont" @click="goback" style="font-size:27px;margin-right: 5px">
      &#xee18;
    </div>
    <div class="search">
      <van-icon style="padding-left:10px;line-height: 40px" class="icon_font" name="search" />
      <input v-model="valeS" @focus="ifshow" type="text" style="position: absolute; height: 30px;width:60%;border: 0;color: #666;top: 8px">
      <span class="search_btn" @click="haveSearch">搜索</span>
    </div>
  </div>
</template>

<script>

import router from "../router";

export default {
  name: "HeaderInput",
  props:['searchValue'],
  data(){
    return{
      valeS:""
    }
  },
  watch:{
    searchValue(val){
      //技术点总结
      if(val.charAt(0)!='<'){
        this.valeS=val
      }
      this.$emit('doSearch',{searchVal:this.searchValue})
      this.$emit('showHistory',{show:false })
    },
    valeS(val){
      this.$emit('doSearch',{searchVal:val})
    }
  },
  methods:{
    goback(){
      router.back()
    },
    haveSearch(){
      this.$emit('showHistory',{show:false })
      this.$emit('Search')
    },
    ifshow(){
      this.$emit('showHistory',{show:true })
    }
  }
}

</script>

<style lang="less" scoped>
@import "../assets/style/theme";
.page-container{
  position: relative;
  .icon_font{
    font-size: 25px;
    font-weight: bold;
    color: #ccc;
  }
  width: 100%;
  height: 50px;
  background-color:@theme;
  display: flex;
  justify-content:right;
  align-items: center;
  .search{
    width: 90%;
    height: 40px;
    background-color: #fff;
    border-radius: 20px;
    line-height: 40px;
    border: 1px solid red;
    .search_btn{
      float: right;
      height: 38px;
      width: 70px;
      margin-top: 1px;
      margin-right: 1px;
      border-radius: 20px;
      text-align: center;
      background-color:firebrick;
    }

  }
}
</style>
